#!/usr/bin/env python
# -*- coding: utf-8 -*-
from typing import TYPE_CHECKING

from sqlalchemy import Column, ForeignKey, Integer, String, text, TIMESTAMP
from sqlalchemy.orm import relationship

from app.db.base_class import Base


class Instrument(Base):
    __tablename__ = 'tb_instrument'
    id = Column(Integer, primary_key=True, index=True)
    symbol = Column(String(20), index=True)
    name = Column(String(20), index=True)
    quote = Column(String(20))
    base = Column(String(20))
    pricePrecision = Column('price_precision', Integer)
    amountPrecision = Column('amount_precision', Integer)
    symbolPartition = Column('symbol_partition', String(20))
    industry = Column(String(20))
    area = Column(String(20))
    nameLetter = Column('name_letter', String(20))
    createdDate = Column('created_date', TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'))
    updatedDate = Column('updated_date', TIMESTAMP, server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))
    marketType = Column('market_type', String(2))
    countryCode = Column('country_code', String(10))
    exchange = Column('exchange', String(10))
    areaId = Column('area_id', Integer)
    exchangeId = Column('exchange_id', Integer)
    limits = Column('limits', String(128))
    precision = Column('precision', String(255))

    # platform = relationship('Platform', back_populates='instruments')

    # def __getitem__(self, item):
    #     return self.__getattribute__(item)